# *-*- coding:utf-8 -*-
# @Author  : Eliza
# @Time    : 2021/7/17 23:36
# @Software : RubyMine
=begin
  多行备注
=end
# __END__ 之后全为注释
# 定义数组
arrays = [1, 2, 3, 4, "as", true]
puts arrays
puts "----arrays[i]------"
puts arrays[0]
puts arrays[-1] #与python相同

puts "----.each do |game|------"
arrays.each do |value|
  puts "含有：#{value}"
end
puts "----.each_index do |index, nothing|------"
arrays.each_index do |index, nothing|
  puts "#{index},#{nothing}"
end

puts "---.each_with_index do |value, index|--------"
arrays.each_with_index do |value, index|
  puts "#{index}:#{value}"
end

puts arrays.join(":") #数组个元素链接,string ，间隔 ：

# 是否为 数组，是否有each方法
if arrays.respond_to?("each")
  puts "arrays is array"
end
puts "-------------"
puts arrays[0].object_id
puts arrays[1].object_id
puts arrays[2].object_id
puts arrays[3].object_id
puts arrays[4].object_id
puts arrays[5].object_id
# ..闭区间
# ... 开区间
puts "-------------"
puts arrays[0..3] #1~4
puts "-------------"

puts arrays[0...3] #1~3
puts arrays.[](0) #1